<?php
/**
 * Created by PhpStorm.
 * User: spatra
 * Date: 14-11-24
 * Time: 下午8:04
 */

class Lesson_Discussion_Reply extends Eloquent
{
    public function discussion()
    {
        return $this->belongsTo('Lesson_Discussion', 'discussion_id', 'id');
    }

    public function creater()
    {
        return $this->hasOne('User', 'id', 'creater_id');
    }


    public static function  getDiscussionReplies($discussionId, array $keys = null)
    {
        return static::with('creater')
            ->where('discussion_id', $discussionId)
            ->get($keys)
            ->toArray();
    }

    protected $touches = ['discussion'];

    protected $guarded =['id'];

    protected $table = 'lesson_discussion_replies';
}